//
//  ServicemanCell.swift
//  Xiaozihui
//
//  Created by 校企荟 on 2017/10/10.
//  Copyright © 2017年 校企荟. All rights reserved.
//

import UIKit

class ServicemanCell: BaseTableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    override func setupUI() {
        let bgView = UIView()
        bgView.backgroundColor = #colorLiteral(red: 1, green: 0.9450980392, blue: 0.9529411765, alpha: 1)
        contentView.addSubview(bgView)
        bgView.snp.makeConstraints { (make) in
            make.top.bottom.equalTo(contentView);
            make.left.equalTo(contentView)
            make.right.equalTo(contentView)
            make.height.equalTo(256 * ScaleX)
        }

        let titleArray:[String] = ["全部资产","报修次数","已完成订单","未完成订单"]
        let countArray:[Int] = [1,2,3,0]
        
        for index in 0...3 {
              let view = createView(title: titleArray[index], count: countArray[index])
            bgView.addSubview(view)
            view.frame = CGRect(x: 0, y: index * 64, width: Int(ScreenWidth), height: 64)
        }
        
      
        
    }
    
    func createView(title:String, count:Int) -> UIView {
        let view = UIView()
        
        let lbl = UILabel(content: title, textFont: UIFont.systemFont(ofSize: 14 * ScaleX), color: mainColor, alignment: .center, numberOfLine: 1)
        
        let countLbl = UILabel(content: "\(count)条", textFont: UIFont.systemFont(ofSize: 14 * ScaleX), color: mainColor, alignment: .center, numberOfLine: 1)
        
        view.addSubview(lbl)
        lbl.snp.makeConstraints { (make) in
            make.centerY.equalTo(view)
            make.left.equalTo(view).offset(82 * ScaleX)
        }
        
        view.addSubview(countLbl)
        countLbl.snp.makeConstraints { (make) in
            make.centerY.equalTo(view)
            make.left.equalTo(view).offset(180 * ScaleX)
        }
        
        let lineView = UIView()
        lineView.backgroundColor = #colorLiteral(red: 0.937254902, green: 0.8745098039, blue: 0.8823529412, alpha: 1)
        view.addSubview(lineView)
        lineView.snp.makeConstraints { (make) in
            make.bottom.equalTo(view)
            make.left.right.equalTo(view)
            make.height.equalTo(1)
        }
        
        return view
        
    }
    
    
}
